//
//  BaseViewController.m
//  YuanyangJinlou
//
//  Created by mac004 on 2016/12/26.
//  Copyright © 2016年 suli19910309@qq.com. All rights reserved.
//

#import "YYJLBaseViewController.h"
#import "AppDelegate.h"
@implementation YYJLBaseViewController

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:NO];
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:NO];
}

-(void)viewDidLoad{
    self.view.backgroundColor=UIColorFromHex(0xf5f5f5);
}
//返回按钮
- (void)setBackItem{
    UIImage *img = [UIImage imageNamed:@"fanhui"];
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(5, 0, img.size.width, img.size.height);
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btn.titleLabel setFont:[UIFont boldSystemFontOfSize:17]];
    [btn setImage:img forState:UIControlStateNormal];
    [btn setImage:img forState:UIControlStateHighlighted];
    [btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    //    [btn setImageEdgeInsets:UIEdgeInsetsMake(0, -10, 0, 0)];
    UIBarButtonItem *leftButton=[[UIBarButtonItem alloc]initWithCustomView:btn];
    self.navigationItem.leftBarButtonItem = leftButton;

}

- (void)back{
     [self.navigationController popViewControllerAnimated:YES];
}
- (void)setLeftBarItem:(UIView *)view
{
    
//    UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
//    spacer.width = -6;
//    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:view];
//    self.navigationItem.leftBarButtonItems = @[spacer,leftItem];
    
}

- (void)setRightBarItems:(UIView *)view
{
    //    解决系统默认占位
    UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
   // spacer.width = -6;
    
    UITapGestureRecognizer * tap =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(right)];
    view.userInteractionEnabled=YES;
   // [view addGestureRecognizer:tap];
    
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:view];
    
    self.navigationItem.rightBarButtonItems = @[spacer,rightItem];
}
-(void)right:(UITapGestureRecognizer*)tap{
    //自己去写
}

//标题
- (void)setTitleView:(NSString *)title{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
    label.text = title;
    label.font = [UIFont fontWithName:HSGBW3 size:18*PER_WIDTH];
    
    label.textColor = UIColorFromHex(0x333333);
    label.backgroundColor = [UIColor clearColor];
    [label sizeToFit];
    self.navigationItem.titleView = label;

}
- (void)setTitleText:(NSString *)title Color:(UIColor *)color{

}

@end
